<?php

	class GetGeocodingCommand implements ICommand
	{
		public function execute($event)
		{
			$address = urlencode($event->data);
			
			$url = "http://maps.google.com/maps/geo?q=".$address."&output=csv";
			
			$response = @file_get_contents($url);
			
			if (!is_null($response) && substr($response,0,3) == "200")
			{
				$response = explode(",",$response);
				 
				$lat = $response[2];
				$lon = $response[3];
				
				return (object) array('lat' => $lat,'lon' => $lon);
				 
			} 
			else 
			{
				return null;
			}			
		}
	}